# coding:utf8
'''
Tasks to be released and their schema
'''


class Task():
    '''
    Release task schema.
    '''

    __slots__ = ['tables', 'colnames', 'msg_column', 'time_column', 'topic', 'classification']

    def __init__(self, tables, colnames, msg_column, time_column, topic, classification):
        '''
        tables: related tables
        colnames: column names
        time_column: column name of timestamp
        topic: target topic
        classification: alias for topic
        '''
        self.tables = tables
        self.colnames = colnames
        self.msg_column = msg_column
        self.time_column = time_column
        self.topic = topic
        self.classification = classification


TASKS = [
    Task(tables=['os_linux', 'db_oracle_11g', 'mw_redis',
                 'dcos_container', 'dcos_docker'],
         colnames=['itemid', 'name', 'bomc_id', 'timestamp', 'value', 'cmdb_id'],
         msg_column='timestamp',
         time_column='timestamp',
         topic='platform-index',
         classification='平台指标'),
    Task(tables=['esb', ],
         colnames=['serviceName', 'startTime', 'avg_time', 'num',
                   'succee_num', 'succee_rate'],
         msg_column='startTime + 60000',
         time_column='startTime',
         topic='business-index',
         classification='业务指标'),
    Task(tables={'trace_csf': 'CSF', 'trace_osb': 'OSB',
                 'trace_remote_process': 'RemoteProcess',
                 'trace_fly_remote': 'FlyRemote'},
         colnames=['startTime', 'elapsedTime', 'success', 'traceId', 'id',
                   'pid', 'cmdb_id', 'serviceName'],
         msg_column='msgTime',
         time_column='startTime',
         topic='trace',
         classification='调用链指标'),
    Task(tables={'trace_jdbc': 'JDBC', },
         colnames=['startTime', 'elapsedTime', 'success', 'traceId', 'id',
                   'pid', 'cmdb_id', 'dsName'],
         msg_column='msgTime',
         time_column='startTime',
         topic='trace',
         classification='调用链指标'),
    Task(tables={'trace_local': 'LOCAL', },
         colnames=['startTime', 'elapsedTime', 'success', 'traceId', 'id',
                   'pid', 'cmdb_id', 'serviceName', 'dsName'],
         msg_column='msgTime',
         time_column='startTime',
         topic='trace',
         classification='调用链指标'),
]
